<?php
declare (strict_types=1);

namespace app\api\controller\v5;

use app\common\models\Datum;

class GroupRead extends BaseController
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $unit_id = input('unit_id/d', 0);
        $page = input('page/d', 1);
        $model = new Datum();
        $rows = $model->where(['unit_id' => $unit_id, 'status' => 1])->count();
        if ($page > $rows)
            return errMsg(400, '暂无数据...');
        $data = $model->where(['unit_id' => $unit_id, 'status' => 1])->page($page, 1)->select();
        foreach ($data as &$v) {
            if ($v['video'])
                $v['video'] = config("app.domain_url") . $v['video'];
        }
        return sucessMsg(200, '获取成功', ['data' => $data, 'total' => $rows, 'maxPage' => $rows]);
    }
}
